﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="manage_sendemail.aspx.cs"
    Inherits="Com.CMS263.Web.manage.manage_sendemail" %>

<%@ Import Namespace="Com.CMS263.Util" %>
<%@ Import Namespace="Com.CMS263.PO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <link href="style/main.css" rel="stylesheet" type="text/css" />
    <link href="common/validator.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>

    <script type="text/javascript" language="javascript" src="/manage/js/pager.js"></script>

    <script type="text/javascript" language="javascript">
        function del(id, obj) {
            if (confirm('这是一个不可逆的操作，真的要删除此条记录')) {
                $.post("comm_action.aspx?op=delsendemail", { id: id }, function(data) {
                    if (data == "ok") {
                        alert('删除成功');
                        $(obj.parentNode.parentNode).remove();
                    }
                })
            }
        }
        function searchByKey() {
            var key = $("#searchKey").val();
            window.location.href = "?email=" + key;
        }
        $(function() {
            $("#chkAll").click(function() {
                if (this.checked) {
                    $("input[name='ckb']").each(function() { this.checked = true; });

                } else {
                    $("input[name='ckb']").each(function() { this.checked = false; });

                }
            })
        })
        function send() {

            if (GetBatchEmail()) {
                
                $("#hfSendType").attr("value", 1);
                $("#sendmail").hide();
                $("#sendmail").show(1000);
            }
            

        }
        function sendall() {

            $("#hfSendType").attr("value", 0);
            $("#sendmail").hide();
            $("#sendmail").show(1000);


        }
        function getEditorHTMLContents(EditorName) {
            var oEditor = FCKeditorAPI.GetInstance(EditorName);
            return (oEditor.GetXHTML(true));
        }

        function check() {
            var title = $("#txtTitle").attr("value");
            if (title.length < 1) {
                alert("请输入发送标题")
                return false;            
            }
            var title1 = getEditorHTMLContents("Hidden1");
            if (title1.length < 10) {
                alert("请输入发送内容");
                return false;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table id="tabtab" width="96%" border="0" align="center" cellpadding="0" cellspacing="0"
            class="table_1">
            <tr>
                <td height="23" colspan="2" class="table_2">
                    邮件订阅
                </td>
            </tr>
            <tr>
                <td class="tdside" align="center">
                    <table id="tab" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
                        class="table_1">
                        <tr class="table_2">
                            <td colspan="4">
                                <div style="float: right; padding-right: 10%;">
                                    <input id="searchKey" style="width: 100px; height: 12px" type="text" value='<%=Request["email"] %>' /><input
                                        style="width: 40px" type="button" onclick="searchByKey()" value="搜索" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th align="center" style="width: 5%">
                                <input name="chkbox" type="checkbox" id="chkAll" />全选/反选
                            </th>
                            <th style="width: 10%">
                                用户名
                            </th>
                            <th>
                                邮箱
                            </th>
                            <th>
                                操作<img title="加载中,请稍等..." style="display: none" id="loading" src="/manage/images/loading.gif" />
                            </th>
                        </tr>
                        <% foreach (SendEmail q in list)
                           {%>
                        <tr>
                            <td align="center" class="style1">
                                <input name="ckb" value="<%=q.UserEmail %>" type="checkbox" id="chk<%=q.Id %>" />
                            </td>
                            <td>
                                <%=q.UserName %>
                            </td>
                            <td>
                                <%=q.UserEmail %>
                            </td>
                            <td>
                                <input type="button" style="width: 40px" onclick="del(<%=q.Id %>,this)" value="删除" />
                            </td>
                        </tr>
                        <%} %>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="tdside">
                    <div id="divpager" style="float: right">
                        <%=GetPager() %></div>
                    <div style="float: left">
                        <input type="button" onclick="send()" value="发邮件给选中用户" />
                        <input type="button" onclick="sendall()" value="发送给全部用户" /></div>
                </td>
            </tr>
            <tr>
                <td class="tdside">
                    <table id="sendmail" style="display: none" width="100%" border="0" align="center"
                        cellpadding="0" cellspacing="0" class="table_1">
                        <tr>
                            <td class="tdleft">
                                发送主题:
                            </td>
                            <td class="tdside">
                                <asp:TextBox ID="txtTitle" runat="server" MaxLength="200" Width="550px"></asp:TextBox><asp:HiddenField
                                    ID="hfSendType" Value="0" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td class="tdleft">
                                发送内容:
                            </td>
                            <td class="tdside">
                                <input type='hidden' id='Hidden1' name='con' runat="server" /><iframe id='Iframe1'
                                    src='/fckeditor/editor/fckeditor.html?InstanceName=Hidden1&amp;Toolbar=Default'
                                    width='100%' height='250px' frameborder='no' scrolling='no'></iframe>
                            </td>
                        </tr>
                        <tr>
                            <td class="tdside" colspan="2">
                                <asp:Button ID="btnSend" Width="40px" runat="server" Text="发送" OnClientClick="return check()"
                                    OnClick="btnSend_Click" /><span style="color: Red">点击发送后,请耐心等待几分钟...</span>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
